package LeetCode.month04.day103;

/**
 * @author 16778
 * @date 2025/11/13 8:04
 * @description
 */
public class No3228 {
    public int maxOperations(String s) {
        int n = s.length();
        int res = 0;
        int cnt1 = 0;
        for (int i = 0; i < n; i++) {
            if(s.charAt(i)!='1'){
                continue;
            }
            if(s.charAt(Math.max(i-1,0))=='0') {
                res += cnt1;
            }
            cnt1++;
        }
        if(s.charAt(s.length()-1)=='0'){
            res+=cnt1;
        }
        return res;
    }
}
